package com.axcbd.demo.controller;

import com.axcbd.demo.dto.response.ApiResponse;
import com.axcbd.demo.model.Camera;
import com.axcbd.demo.repository.CameraRepository;
import com.axcbd.demo.service.CameraService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/camera")
public class CameraController {

    @Autowired
    private CameraService cameraService;

    @PostMapping("/add")
    public ResponseEntity<ApiResponse<Camera>> AddCamera(@RequestBody  Camera camera) {
        Camera newcamera = cameraService.AddCamera(camera);
        return ResponseEntity.status(HttpStatus.CREATED).body(new ApiResponse<>(newcamera));
    }

}
